package com.project.common.core.utils;

import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.Objects;


/**
 * @ClassName ListUtils
 * @Description
 * @Author 王天豪
 * @Date 2020/7/27 6:10 PM
 * @Version 1.0
 */

public class ListUtils {

    public static void copyList(Object obj, List list, Class classObj) {
        if ((!Objects.isNull(obj)) ) {
            List list1 = (List) obj;
            list1.forEach(item -> {
                try {
                    Object o = classObj.newInstance();
                    BeanUtils.copyProperties(item, o);
                    list.add(o);
                } catch (InstantiationException e) {
                } catch (IllegalAccessException e) {
                }
            });
        }
    }
}

